package com.crl.module.cmpRpc.model
{
	import com.crl.core.config.IXMLBindable;
	import com.crl.module.cmpRpc.parsers.XMLParser;
	import com.crl.utils.StringUtil;
	
	import flash.utils.Dictionary;
	import flash.utils.getQualifiedClassName;
	
	
	/**
	 * 远程请求的参数持久化对像;
	 * @author crl
	 * 
	 */	
	public class RequestVO implements IXMLBindable
	{
		public var connectionKey:String;
		public var method:String;
		public var descript:String;
		
		public var parms:Dictionary;
		
		
		public var parser:String;
		public var mapping:String;
		
		
		private static var parsers:Dictionary=new Dictionary();{
			parsers["XMLParser"]=getQualifiedClassName(XMLParser);
		}
		
		public function RequestVO()
		{
		}
		
		
		public function bindXML(xml:XML):void{
			this.method=xml.@name;
			this.descript=xml.@descript;
			
			this.connectionKey=xml..connection[0].@key;
			
			parms=new Dictionary(true);
			
			var pa:XMLList=xml.descendants("parm");
			
			
			
			for each(var item:XML in pa){
				parms[item.@service.toString()]=item.@key.toString();
			}
			
			
			var result:XML=xml..result[0];
			if(result==null)return;
			
			this.parser=StringUtil.trim(result.@parser);
			if(parsers.hasOwnProperty(this.parser)){
				this.parser=parsers[this.parser];
			}
			this.mapping=StringUtil.trim(result.@mapping);
		}
	}
}